/**
 * @author Clark
 * @email haixuanwoTxh@gmail.com
 * @date 2021-10-30
 */
#include <stdio.h>

#define MAXLINE 1000    // 允许的输入行最大长度

int get_line(char line[], int maxline);
void copy(char to[], char from[]);

int main(int argc, char *argv[])
{
    int len;    // 当前行长度
    int max;    // 最长行长度
    char line[MAXLINE]; // 当前输入行
    char longest[MAXLINE];  // 用于保存最长的行

    max = 0;
    while ((len = get_line(line, MAXLINE)) > 0)
    {
        if (len > max)
        {
            max = len;
            copy(longest, line);
        }
    }

    if (max > 0)
        printf("%s", longest);
    return 0;
}

int get_line(char s[], int lim)
{
    int c, i;

    for (i = 0; i < lim - 1 && (c = getchar()) != EOF && c != '\n'; ++i)
        s[i] = c;

    if ('\n' == c)
    {
        s[i] = c;
        ++i;
    }

    s[i] = '\0';
    return i;
}

void copy(char to[], char from[])
{
    int i;

    i = 0;
    while ((to[i] = from[i]) != '\0')
        ++i;
}
